package com.itheima.xmy.Demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTest {
    public static void main(String[] args) {
        //创建集合对象
        Collection<Movie> collection = new ArrayList<>();

        //创建电影对象
        Movie movie1 = new Movie("肖申克的救赎", "The Shawshank Redemption",
                1994, "演员表：希姆·罗宾斯", "弗兰克·德拉邦特");
        Movie movie2 = new Movie("霸王别姬", "Farewell My Concubine",
                1993, "演员表：张国荣，张丰毅", "陈凯歌");
        Movie movie3 = new Movie("阿甘正传", "Forrest Gump",
                1994, "演员表：汤姆·汉克斯", "罗伯特·泽米基斯");

        //添加元素
        collection.add(movie1);
        collection.add(movie2);
        collection.add(movie3);

        System.out.println(collection);
        //增强for遍历
        for (Movie movie : collection) {
            System.out.println(movie.getName()+"   "+movie.getEnglishName()+"   "+movie.getShowTime()+"   "+movie.getActor()+"   "+movie.getDirector());
        }
        System.out.println("----------------------------------");
        Iterator<Movie> iterator = collection.iterator();
        while (iterator.hasNext()) {
            Movie next =  iterator.next();
            System.out.println(next);
        }
    }
}
